]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
test-tool: Set up GSettings keyfile
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 27 Nov 2025 15:29:44 +0000 (16:29 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Thu, 27 Nov 2025 18:24:01 +0000 (19:24 +0100)
Even with a separate XDG_CONFIG_HOME, settings may still be picked
up from the session's dconf instance (although the tool is typically
run through dbus-run-session).

To really ensure that we control the settings, we can force a different
backend. The 'memory' backend would be enough to ensure default values,
however using the 'keyfile' backend means we can also inject non-default
values.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3986>

src/gnome-shell-test-tool.in

index 35380da6618b1197094c9ae23db76b3de079778a..43348f126cb90c8eefe6b52ee6a285d3006ded70 100755 (executable)
@@ -11,6 +11,20 @@ import os
 import subprocess
 import sys
 import tempfile
+from configparser import ConfigParser
+from pathlib import Path
+
+class GSettingsConfig(ConfigParser):
+    def add(self, path, key, value):
+        if not path in self:
+            self[path] = {}
+        self[path][key] = value
+
+    def save(self, xdg_home):
+        dir = f'{xdg_home}/config/glib-2.0/settings'
+        Path(dir).mkdir(parents=True)
+        with open(f'{dir}/keyfile', 'w') as keyfile:
+            self.write(keyfile)
 
 def show_version(option, opt_str, value, parser):
     print("GNOME Shell Test Tool @VERSION@")
@@ -30,6 +44,10 @@ def start_shell(xdg_home, wrap=None, perf_output=None):
     if perf_output is not None:
         env['SHELL_PERF_OUTPUT'] = perf_output
 
+    env['GSETTINGS_BACKEND'] = 'keyfile'
+
+    gsettings_config = GSettingsConfig()
+
     # A fixed background image
     if os.getenv('SHELL_BACKGROUND_IMAGE') is None:
       env['SHELL_BACKGROUND_IMAGE'] = '@pkgdatadir@/perf-background.xml'
@@ -58,6 +76,8 @@ def start_shell(xdg_home, wrap=None, perf_output=None):
         args.append('--wayland-display')
         args.append('gnome-shell-test-display')
 
+    gsettings_config.save(xdg_home)
+
     print("args: {}".format(args))
     return subprocess.Popen(args, env=env)